cd C:\Users\alen_\Dropbox\burning_glass\data

***** 2018 01
cd D:\burning_glass_posting\2018_01

foreach j of numlist 2(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)230 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)230 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 02
cd D:\burning_glass_posting\2018_02

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)230 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)230 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2018 03
cd D:\burning_glass_posting\2018_03

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)230 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)230 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 04
cd D:\burning_glass_posting\2018_04

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 05
cd D:\burning_glass_posting\2018_05

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 06
cd D:\burning_glass_posting\2018_06

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 07
cd D:\burning_glass_posting\2018_07

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 08
cd D:\burning_glass_posting\2018_08

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2018 09
cd D:\burning_glass_posting\2018_09

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 10
cd D:\burning_glass_posting\2018_10

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


***** 2018 11
cd D:\burning_glass_posting\2018_11

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2018 12
cd D:\burning_glass_posting\2018_12

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}





***** 2019 01
cd D:\burning_glass_posting\2019_01

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2019 02
cd D:\burning_glass_posting\2019_02

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


***** 2019 03
cd D:\burning_glass_posting\2019_03

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2019 04
cd D:\burning_glass_posting\2019_04

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2019 05
cd D:\burning_glass_posting\2019_05

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2019 06
cd D:\burning_glass_posting\2019_06

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2019 07
cd D:\burning_glass_posting\2019_07

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2019 08
cd D:\burning_glass_posting\2019_08

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2019 09
cd D:\burning_glass_posting\2019_09

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2019 10
cd D:\burning_glass_posting\2019_10

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2019 11
cd D:\burning_glass_posting\2019_11

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2019 12
cd D:\burning_glass_posting\2019_12

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


***** 2020 01
cd D:\burning_glass_posting\2020_01

foreach j of numlist 0(1)0 {
foreach i of numlist 6(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}

******

import delimited "data_0_2_0.json",  colrange(2:2) clear

g rank=_n

save temp_body, replace 

import delimited "data_0_2_0.json",  colrange(3:300) delimiter(comma) clear

g id_string=""

foreach num of numlist 1(1)298 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)298 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_0_2_0", replace


*******


import delimited "data_2_5_0.json",  colrange(2:2) clear

g rank=_n

save temp_body, replace 

import delimited "data_2_5_0.json",  colrange(3:300) delimiter(comma) clear

g id_string=""

foreach num of numlist 1(1)298 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)298 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_2_5_0", replace


*************************************************
**************************************************
*** 2020 02 

cd D:\burning_glass_posting\2020_02

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}







*************************************************
**************************************************
*** 2020 03 

cd D:\burning_glass_posting\2020_03

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 04

cd D:\burning_glass_posting\2020_04

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



cd D:\burning_glass_posting\2020_04


import delimited "data_3_3_0.json",  colrange(2:2) clear

g rank=_n

save temp_body, replace 

import delimited "data_3_3_0.json",  colrange(3:300) delimiter(comma) clear

g id_string=""

foreach num of numlist 1(1)298 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)298 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_3_3_0", replace





*************************************************
**************************************************
*** 2020 05

cd D:\burning_glass_posting\2020_05

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



*************************************************
**************************************************
*** 2020 06

cd D:\burning_glass_posting\2020_06

foreach j of numlist 3(1)3 {
foreach i of numlist 1(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 07

cd D:\burning_glass_posting\2020_07

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 08

cd D:\burning_glass_posting\2020_08

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 09

cd D:\burning_glass_posting\2020_09

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 10

cd D:\burning_glass_posting\2020_10

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 11

cd D:\burning_glass_posting\2020_11

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2020 12

cd D:\burning_glass_posting\2020_12

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}





***** 2021 01
cd D:\burning_glass_posting\2021_01

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2021 02
cd D:\burning_glass_posting\2021_02

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2021 03
cd D:\burning_glass_posting\2021_03

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}





***** 2021 04
cd D:\burning_glass_posting\2021_04

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}






***** 2021 05
cd D:\burning_glass_posting\2021_05

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2021 06
cd D:\burning_glass_posting\2021_06

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2021 07
cd D:\burning_glass_posting\2021_07

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




***** 2021 08
cd D:\burning_glass_posting\2021_08

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2021 09
cd D:\burning_glass_posting\2021_09

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2021 10
cd D:\burning_glass_posting\2021_10

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2021 11
cd D:\burning_glass_posting\2021_11

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}



***** 2021 12
cd D:\burning_glass_posting\2021_12

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)290 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)290 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}
*************************************************
**************************************************
*** 2022 01

cd D:\burning_glass_posting\2022_01

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}





*************************************************
**************************************************
*** 2022 02

cd D:\burning_glass_posting\2022_02

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2022 03

cd D:\burning_glass_posting\2022_03

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


*************************************************
**************************************************
*** 2022 04

cd D:\burning_glass_posting\2022_04

foreach j of numlist 0(1)0 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}









*************************************************
**************************************************
*** 2022 05

cd D:\burning_glass_posting\2022_05

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2022 06

cd D:\burning_glass_posting\2022_06

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2022 07

cd D:\burning_glass_posting\2022_07

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2022 08

cd D:\burning_glass_posting\2022_08

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*************************************************
**************************************************
*** 2022 09

cd D:\burning_glass_posting\2022_09

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
capture	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
capture	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}

*************************************************
**************************************************
*** 2022 10

cd D:\burning_glass_posting\2022_10

foreach j of numlist 1(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


*************************************************
**************************************************
*** 2022 11

cd D:\burning_glass_posting\2022_11

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}


*************************************************
**************************************************
*** 2022 12

cd D:\burning_glass_posting\2022_12

foreach j of numlist 0(1)3 {
foreach i of numlist 0(1)7 {
import delimited "data_`j'_`i'_0.json",  colrange(1:1) clear

g rank=_n

save temp_body, replace 

import delimited "data_`j'_`i'_0.json",  colrange(2:300) clear

g id_string=""

foreach num of numlist 1(1)299 {
	replace id_string=substr(v`num',6,15) if substr(v`num',1,2)=="id"
}
destring id_string, g(bgtjobid) force

g remote_type_name=""
foreach num of numlist 1(1)299 {
	replace remote_type_name=substr(v`num',20,10) if substr(v`num',1,16)=="remote_type_name"
}

keep bgtjobid remote_type_name 

g rank=_n 

save temp_id, replace


u temp_body, clear

merge 1:1 rank using temp_id
keep if _merge==3
drop _merge 

drop if bgtjobid==.

g description=substr(v1,10,10000)

keep bgtjobid remote_type_name description

save "description_`j'_`i'_0", replace

}
}




*********************************************************
*********************** Definitions 



foreach year of numlist 2018(1)2022 {
    foreach num of numlist 1(1)9 {

foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd "D:\burning_glass_posting\\`year'_0`num'"
u "description_`i'_`j'_0", clear

g remote_type=0 if remote_type_name=="[None]"
replace remote_type=1 if remote_type_name=="Remote"
replace remote_type=2 if remote_type_name=="Not Remote"
replace remote_type=3 if remote_type_name=="Hybrid Rem"

keep bgtjobid remote_type
cd D:\burning_glass_posting
save "bg_remote_`i'_`j'_0", replace
}
}


clear all
cd D:\burning_glass_posting

foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "bg_remote_`i'_`j'_0"
}
}

cd C:\Users\alen_\Dropbox\burning_glass\data\remote_compatible

save "remote_id_`year'_0`num'", replace

}


    foreach num of numlist 10(1)12 {

foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd "D:\burning_glass_posting\\`year'_`num'"
u "description_`i'_`j'_0", clear

g remote_type=0 if remote_type_name=="[None]"
replace remote_type=1 if remote_type_name=="Remote"
replace remote_type=2 if remote_type_name=="Not Remote"
replace remote_type=3 if remote_type_name=="Hybrid Rem"

keep bgtjobid remote_type
cd D:\burning_glass_posting
save "bg_remote_`i'_`j'_0", replace
}
}


clear all
cd D:\burning_glass_posting

foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "bg_remote_`i'_`j'_0"
}
}

cd C:\Users\alen_\Dropbox\burning_glass\data\remote_compatible

save "remote_id_`year'_`num'", replace

}
}





***** Create remote dummy using dictionary 
*** 2018
foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2018_0`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2018_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2018_`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}


save remote_dictionary_2018_`num', replace
}

*** 2019 

foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2019_0`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2019_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2019_`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}


save remote_dictionary_2019_`num', replace
}


*** 2020 

foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2020_0`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2020_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2020_`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}


save remote_dictionary_2020_`num', replace
}



** 2021
foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2021_0`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2021_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2021_`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2021_`num', replace
}


*** 2022
foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2022_0`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2022_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2022_`num'
u "description_`i'_`j'_0", clear


replace description=strlower(description)

g remote=strpos(description,"remote")
g telework=strpos(description,"telework")
g work_from_home=strpos(description,"work from home")
g work_at_home=strpos(description,"work at home")
g wfh=strpos(description,"wfh")
g home_office=strpos(description,"home office")
g virtual=strpos(description,"virtual")
g work_anywhere=strpos(description,"work anywhere")
g mobile_office=strpos(description,"mobile office")

g remote_dummy=0
replace remote_dummy=1 if remote>0 | telework>0 | work_from_home>0 | work_at_home>0 | wfh>0 | home_office>0 | virtual>0 | work_anywhere>0 | mobile_office>0

save temp, replace 

keep if remote_dummy==1 
g negate=0

foreach word in "remote" "telework" "work_from_home" "work_at_home" "wfh" "home_office" "virtual" "work_anywhere" "mobile_office" {
replace negate=1 if strpos(description," aint ")>`word'-20 & strpos(description," aint ")<`word' & strpos(description," aint ")>0 & `word'>0
replace negate=1 if strpos(description," arent ")>`word'-20 & strpos(description," arent ")<`word' & strpos(description," arent ")>0 & `word'>0
replace negate=1 if strpos(description," cannot ")>`word'-20 & strpos(description," cannot ")<`word' & strpos(description," cannot ")>0 & `word'>0
replace negate=1 if strpos(description," cant ")>`word'-20 & strpos(description," cant ")<`word' & strpos(description," cant ")>0 & `word'>0
replace negate=1 if strpos(description," couldnt ")>`word'-20 & strpos(description," couldnt ")<`word' & strpos(description," couldnt ")>0 & `word'>0
replace negate=1 if strpos(description," darent ")>`word'-20 & strpos(description," darent ")<`word' & strpos(description," darent ")>0 & `word'>0
replace negate=1 if strpos(description," didnt ")>`word'-20 & strpos(description," didnt ")<`word' & strpos(description," didnt ")>0 & `word'>0
replace negate=1 if strpos(description," doesnt ")>`word'-20 & strpos(description," doesnt ")<`word' & strpos(description," doesnt ")>0 & `word'>0
replace negate=1 if strpos(description," ain't ")>`word'-20 & strpos(description," ain't ")<`word' & strpos(description," ain't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," aren't ")>`word'-20 & strpos(description," aren't ")<`word' & strpos(description," aren't ")>0 & `word'>0
replace negate=1 if strpos(description," can't ")>`word'-20 & strpos(description," can't ")<`word' & strpos(description," can't ")>0 & `word'>0
replace negate=1 if strpos(description," couldn't ")>`word'-20 & strpos(description," couldn't ")<`word' & strpos(description," couldn't ")>0 & `word'>0
replace negate=1 if strpos(description," daren't ")>`word'-20 & strpos(description," daren't ")<`word' & strpos(description," daren't ")>0 & `word'>0
replace negate=1 if strpos(description," didn't ")>`word'-20 & strpos(description," didn't ")<`word' & strpos(description," didn't ")>0 & `word'>0
replace negate=1 if strpos(description," doesn't ")>`word'-20 & strpos(description," doesn't ")<`word' & strpos(description," doesn't ")>0 & `word'>0
replace negate=1 if strpos(description," dont ")>`word'-20 & strpos(description," dont ")<`word' & strpos(description," dont ")>0 & `word'>0
replace negate=1 if strpos(description," don't ")>`word'-20 & strpos(description," don't ")<`word' & strpos(description," don't ")>0 & `word'>0
replace negate=1 if strpos(description," hadnt ")>`word'-20 & strpos(description," hadnt ")<`word' & strpos(description," hadnt ")>0 & `word'>0
replace negate=1 if strpos(description," hasnt ")>`word'-20 & strpos(description," hasnt ")<`word' & strpos(description," hasnt ")>0 & `word'>0
replace negate=1 if strpos(description," havent ")>`word'-20 & strpos(description," havent ")<`word' & strpos(description," havent ")>0 & `word'>0
replace negate=1 if strpos(description," hadn't ")>`word'-20 & strpos(description," hadn't ")<`word' & strpos(description," hadn't ")>0 & `word'>0
replace negate=1 if strpos(description," hasn't ")>`word'-20 & strpos(description," hasn't ")<`word' & strpos(description," hasn't ")>0 & `word'>0
replace negate=1 if strpos(description," haven't ")>`word'-20 & strpos(description," haven't ")<`word' & strpos(description," haven't ")>0 & `word'>0


replace negate=1 if strpos(description," isnt ")>`word'-20 & strpos(description," isnt ")<`word' & strpos(description," isnt ")>0 & `word'>0
replace negate=1 if strpos(description," mightnt ")>`word'-20 & strpos(description," mightnt ")<`word' & strpos(description," mightnt ")>0 & `word'>0
replace negate=1 if strpos(description," mustnt ")>`word'-20 & strpos(description," mustnt ")<`word' & strpos(description," mustnt ")>0 & `word'>0

replace negate=1 if strpos(description," neither ")>`word'-20 & strpos(description," neither ")<`word' & strpos(description," neither ")>0 & `word'>0
replace negate=1 if strpos(description," isn't ")>`word'-20 & strpos(description," isn't ")<`word' & strpos(description," isn't ")>0 & `word'>0
replace negate=1 if strpos(description," mightn't ")>`word'-20 & strpos(description," mightn't ")<`word' & strpos(description," mightn't ")>0 & `word'>0
replace negate=1 if strpos(description," mustn't ")>`word'-20 & strpos(description," mustn't ")<`word' & strpos(description," mustn't ")>0 & `word'>0
replace negate=1 if strpos(description," needn't ")>`word'-20 & strpos(description," needn't ")<`word' & strpos(description," needn't ")>0 & `word'>0
replace negate=1 if strpos(description," never ")>`word'-20 & strpos(description," never ")<`word' & strpos(description," never ")>0 & `word'>0
replace negate=1 if strpos(description," none ")>`word'-20 & strpos(description," none ")<`word' & strpos(description," none ")>0 & `word'>0
replace negate=1 if strpos(description," nope ")>`word'-20 & strpos(description," nope ")<`word' & strpos(description," nope ")>0 & `word'>0
replace negate=1 if strpos(description," nor ")>`word'-20 & strpos(description," nor ")<`word' & strpos(description," nor ")>0 & `word'>0
replace negate=1 if strpos(description," nothing ")>`word'-20 & strpos(description," nothing ")<`word' & strpos(description," nothing ")>0 & `word'>0
replace negate=1 if strpos(description," nowhere ")>`word'-20 & strpos(description," nowhere ")<`word' & strpos(description," nowhere ")>0 & `word'>0

replace negate=1 if strpos(description," oughtnt ")>`word'-20 & strpos(description," oughtnt ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shant ")>`word'-20 & strpos(description," shant ")<`word' & strpos(description," shant ")>0 & `word'>0
replace negate=1 if strpos(description," shouldnt ")>`word'-20 & strpos(description," shouldnt ")<`word' & strpos(description," shouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," wasnt ")>`word'-20 & strpos(description," wasnt ")<`word' & strpos(description," wasnt ")>0 & `word'>0
replace negate=1 if strpos(description," werent ")>`word'-20 & strpos(description," werent ")<`word' & strpos(description," werent ")>0 & `word'>0
replace negate=1 if strpos(description," oughtn't ")>`word'-20 & strpos(description," oughtn't ")<`word' & strpos(description," oughtnt ")>0 & `word'>0
replace negate=1 if strpos(description," shan't ")>`word'-20 & strpos(description," shan't ")<`word' & strpos(description," shan't ")>0 & `word'>0
replace negate=1 if strpos(description," shouldn't ")>`word'-20 & strpos(description," shouldn't ")<`word' & strpos(description," shouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," uhuh ")>`word'-20 & strpos(description," uhuh ")<`word' & strpos(description," uhuh ")>0 & `word'>0
replace negate=1 if strpos(description," uh-uh ")>`word'-20 & strpos(description," uh-uh ")<`word' & strpos(description," uh-uh ")>0 & `word'>0
replace negate=1 if strpos(description," wasn't ")>`word'-20 & strpos(description," wasn't ")<`word' & strpos(description," wasn't ")>0 & `word'>0
replace negate=1 if strpos(description," weren't ")>`word'-20 & strpos(description," weren't ")<`word' & strpos(description," weren't ")>0 & `word'>0
replace negate=1 if strpos(description," without ")>`word'-20 & strpos(description," without ")<`word' & strpos(description," without ")>0 & `word'>0
replace negate=1 if strpos(description," wont ")>`word'-20 & strpos(description," wont ")<`word' & strpos(description," wont ")>0 & `word'>0
replace negate=1 if strpos(description," won't ")>`word'-20 & strpos(description," won't ")<`word' & strpos(description," won't ")>0 & `word'>0
replace negate=1 if strpos(description," wouldnt ")>`word'-20 & strpos(description," wouldnt ")<`word' & strpos(description," wouldnt ")>0 & `word'>0
replace negate=1 if strpos(description," wouldn't ")>`word'-20 & strpos(description," wouldn't ")<`word' & strpos(description," wouldn't ")>0 & `word'>0
replace negate=1 if strpos(description," seldom ")>`word'-20 & strpos(description," seldom ")<`word' & strpos(description," seldom ")>0 & `word'>0
replace negate=1 if strpos(description," despite ")>`word'-20 & strpos(description," despite ")<`word' & strpos(description," despite ")>0 & `word'>0
replace negate=1 if strpos(description," rarely ")>`word'-20 & strpos(description," rarely ")<`word' & strpos(description," rarely ")>0 & `word'>0


replace negate=1 if strpos(description," no ")>`word'-20 & strpos(description," no ")<`word'+length("`word'")+2 & strpos(description," no ")>0 & `word'>0
replace negate=1 if strpos(description," not ")>`word'-20 & strpos(description," not ")<`word'+length("`word'")+2 & strpos(description," not ")>0 & `word'>0
}

replace negate=1 if strpos(description, " fully onsite ")
replace negate=1 if strpos(description, " fully on-site ")
replace negate=1 if strpos(description, " attendance ")
replace negate=1 if strpos(description, " physical appearance ")
replace negate=1 if strpos(description, " physically ")
replace negate=1 if strpos(description, " show up on time ")
replace negate=1 if strpos(description, " in office ")
replace negate=1 if strpos(description, " in person ")
replace negate=1 if strpos(description, " requires onsite ")
replace negate=1 if strpos(description, " requires on-site ")
replace negate=1 if strpos(description, " require onsite ")
replace negate=1 if strpos(description, " require on-site ")
replace negate=1 if strpos(description, " onsite required ")
replace negate=1 if strpos(description, " on-site required ")
replace negate=1 if strpos(description, " onsite only ")
replace negate=1 if strpos(description, " on-site only ")

keep bgtjobid negate 

merge 1:1 bgtjobid using temp
drop _merge 

g remote_dummy_negate=0
replace remote_dummy_negate=remote_dummy if negate==0

keep bgtjobid remote_dummy remote_dummy_negate 

 cd D:\burning_glass_posting
save "remote_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "remote_dictionary_`i'_`j'_0"
}
}

save remote_dictionary_2022_`num', replace
}


***** Onsite job dummy 

*** 2018
foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2018_0`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}

save onsite_dictionary_2018_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2018_`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}


save onsite_dictionary_2018_`num', replace
}


*** 2019 

foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2019_0`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}

save onsite_dictionary_2019_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2019_`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}


save onsite_dictionary_2019_`num', replace
}




foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2020_0`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}

save onsite_dictionary_2020_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2020_`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}


save onsite_dictionary_2020_`num', replace
}




foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2021_0`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}

save onsite_dictionary_2021_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2021_`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}


save onsite_dictionary_2021_`num', replace
}




foreach num of numlist 1(1)9 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2022_0`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}

save onsite_dictionary_2022_0`num', replace
}



foreach num of numlist 10(1)12 {
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
    cd D:\burning_glass_posting\2022_`num'
u "description_`i'_`j'_0", clear

replace description=strlower(description)

g onsite_dummy=0

replace onsite_dummy=1 if strpos(description, " fully onsite ")>0
replace onsite_dummy=1 if strpos(description, " fully on-site ")>0
replace onsite_dummy=1 if strpos(description, " attendance ")>0
replace onsite_dummy=1 if strpos(description, " physical appearance ")>0
replace onsite_dummy=1 if strpos(description, " physically ")>0
replace onsite_dummy=1 if strpos(description, " show up on time ")>0
replace onsite_dummy=1 if strpos(description, " in office ")>0
replace onsite_dummy=1 if strpos(description, " in person ")>0
replace onsite_dummy=1 if strpos(description, " requires onsite ")>0
replace onsite_dummy=1 if strpos(description, " requires on-site ")>0
replace onsite_dummy=1 if strpos(description, " require onsite ")>0
replace onsite_dummy=1 if strpos(description, " require on-site ")>0
replace onsite_dummy=1 if strpos(description, " onsite required ")>0
replace onsite_dummy=1 if strpos(description, " on-site required ")>0
replace onsite_dummy=1 if strpos(description, " onsite only ")>0
replace onsite_dummy=1 if strpos(description, " on-site only ")>0

keep bgtjobid onsite_dummy 

 cd D:\burning_glass_posting
save "onsite_dictionary_`i'_`j'_0", replace
}
}

clear all
cd D:\burning_glass_posting
foreach i of numlist 0(1)3 {
foreach j of numlist 0(1)7 {
append using "onsite_dictionary_`i'_`j'_0"
}
}


save onsite_dictionary_2022_`num', replace
}
*** Calculate the fraction of jobs with remote 

clear all
 cd D:\burning_glass_posting
g year=. 
g month=. 
foreach year of numlist 2018(1)2022 {
    foreach num of numlist 1(1)9 {
append using remote_dictionary_`year'_0`num'
replace month=`num' if month==.
replace year=`year' if year==.
}
    foreach num of numlist 10(1)12 {
append using remote_dictionary_`year'_`num'
replace month=`num' if month==.
replace year=`year' if year==.
}
}

collapse remote_dummy_negate, by(year month)
g year_month=year+month/12 

graph twoway line remote_dummy_negate year_month, graphregion(color(white)) ytitle(Fraction of Job Postings Mentioning Remote Work Options) xtitle(Time)
graph export remote_dummy_time, replace


*** Calculate the prevalence of WFH by occupation 

clear all

cd D:\burning_glass_temp
foreach year of numlist 2018(1)2022 {
append using temp_`year'
keep bgtjobid occfamname onet year
}


merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_01"
drop if _merge==2
drop _merge 

ren remote_dummy_negate remote_job 
drop remote_dummy

merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_02"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate

foreach num of numlist 3(1)9 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_0`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}


foreach num of numlist 10(1)12 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_`num'"
drop if _merge==2
drop _merge 


replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}

foreach year_num of numlist 2019(1)2022 {
foreach num of numlist 1(1)9 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_`year_num'_0`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}


foreach num of numlist 10(1)12 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_`year_num'_`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}
}

g post=0
replace post=1 if year>=2020 & year<.
collapse remote_fraction=remote_job, by(onet post)

save remote_fraction_based_on_bg, replace


*** 
cd D:\burning_glass_temp

u remote_fraction_based_on_bg, clear

reshape wide remote_fraction, i(onet) j(post) 

sort onet

g dremote=remote_fraction1-remote_fraction0

keep onet dremote 

save remote_dummy_based_on_bg, replace



******


*** Calculate the prevalence of WFH by occupation (Based on NAICS 3-digit)

clear all

cd D:\burning_glass_temp
foreach year of numlist 2018(1)2022 {
append using temp_`year'
keep bgtjobid naics3 year
}


merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_01"
drop if _merge==2
drop _merge 

ren remote_dummy_negate remote_job 
drop remote_dummy

merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_02"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate

foreach num of numlist 3(1)9 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_0`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}


foreach num of numlist 10(1)12 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_2018_`num'"
drop if _merge==2
drop _merge 


replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}

foreach year_num of numlist 2019(1)2022 {
foreach num of numlist 1(1)9 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_`year_num'_0`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}


foreach num of numlist 10(1)12 {
merge 1:1 bgtjobid using "D:\burning_glass_posting\remote_dictionary_`year_num'_`num'"
drop if _merge==2
drop _merge 

replace remote_job=remote_dummy_negate if remote_job==. & remote_dummy_negate!=.
drop remote_dummy remote_dummy_negate
}
}

g post=0
replace post=1 if year>=2020 & year<=2021 
replace post=2 if year>=2022 & year<.
collapse remote_fraction=remote_job, by(naics3 post)

save remote_fraction_based_on_bg_naics, replace

cd D:\burning_glass_temp
u remote_fraction_based_on_bg_naics, clear

drop if post==1 

sort naics3 post 

by naics3: g dremote_fraction=remote_fraction-remote_fraction[_n-1]

keep if post==2

drop post remote_fraction

save remote_fraction_based_on_bg_naics_2020_2022, replace